package com.ghsc.ghxc.jsb.ui.my.activity

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.my.bean.UserResultDataBean
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaMall
 * 包名：com.ghsc.ghxc.ui.my.activity
 * 类名：UpNicknameInfoViewModel
 * 创建时间：2023/6/28 11:26
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class UpNicknameInfoViewModel  : BaseViewModel() {
    /**
     * 个人中心
     */
    val onUserInfoData: MutableLiveData<BaseResponse<UserResultDataBean>> = MutableLiveData()
    fun onUserInfoMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onUserInfoData() }
            executeResponse(
                response,
                { onUserInfoData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }
    /**
     * 修改用户信息
     */
    val updateUserInfoData: MutableLiveData<BaseResponse<Any>> = MutableLiveData()
    fun updateUserInfoMethod(paras: String ) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.updateUserInfoData(paras) }
            executeResponse(
                response,
                { updateUserInfoData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }
}